<template>
  <div>child2组件 - {{ count }} - <button @click="add">count++</button></div>
</template>

<script>
export default {
  computed: {
    count() {
      return this.$store.state.count;
    },
  },
  methods: {
    add() {
      // 不能在组件直接改变仓库的数据
      // this.$store.state.count++;

      this.$store.commit("increment");
    },
  },
};
</script>
